package xyz.xmh.pattern.structural.filterpattern;

import java.util.ArrayList;
import java.util.List;

/**
 * CriteriaSingle
 * 是不是单身
 *
 * @author xuMingHai
 * @since 2021/4/30 星期五 14:16
 */
public class CriteriaSingle implements Criteria {
    @Override
    public List<Person> meetCriteria(List<Person> personList) {
        List<Person> singlePersonList = new ArrayList<>();

        // 遍历集合中为单身的
        for (Person person : personList) {

            if ("SINGLE".equalsIgnoreCase(person.getMaritalStatus())) {
                singlePersonList.add(person);
            }
        }

        return singlePersonList;
    }
}
